package org.apache.axis2.json.Utils;

/**
 * Created by IntelliJ IDEA.
 * User: shameera
 * Date: 1/24/12
 * Time: 2:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class TypeMatcher {
    private static final String STRING = "java.lang.String";
    private static final String W_INT = "java.lang.Integer";
    private static final String W_DOUBLE = "java.lang.Double";
    private static final String W_LONG = "java.lang.lONG";
    private static final String W_BOOLEAN = "java.lang.Boolean";
    private static final String INT = "int";
    private static final String BOOLEAN = "boolean";
    private static final String DOUBLE = "double";
    private static final String LONG = "long";


    public static boolean isStringType(Class obj) {
        String  class_name = obj.getName();
        return obj.getName().equals(STRING);

    }

    public static boolean isBooleanType(Class obj) {
        return obj.getName().equals(BOOLEAN);

    }
    public static boolean isDoubleType(Class obj) {
        return obj.getName().equals(DOUBLE);

    }

    public static boolean isIntType(Class obj) {
        return obj.getName().equals(INT);

    }

    public static boolean isLongType(Class obj) {
        return obj.getName().equals(LONG);

    }

    public static boolean isW_BooleanType(Class obj) {
        return obj.getName().equals(W_BOOLEAN);

    }

    public static boolean isW_DoubleType(Class obj) {
        return obj.getName().equals(W_DOUBLE);

    }

    public static boolean isW_IntType(Class obj) {
        return obj.getName().equals(W_INT);

    }

    public static boolean isW_LongType(Class obj) {

        return obj.getName().equals(W_LONG);

    }

    public static boolean isObjectType(Class obj) {
        String  class_name = obj.getName();
        if (class_name.startsWith("java.")) {
            return false;
        }
        return true;
    }

    public static boolean isArrayType(Class obj) {

        return obj.isArray();

    }

    public static boolean isSimpleType(Class obj) {
        return  TypeMatcher.isStringType(obj) ||
                TypeMatcher.isIntType(obj) ||
                TypeMatcher.isBooleanType(obj) ||
                TypeMatcher.isDoubleType(obj) ||
                TypeMatcher.isLongType(obj) ||
                TypeMatcher.isW_BooleanType(obj) ||
                TypeMatcher.isW_DoubleType(obj) ||
                TypeMatcher.isW_IntType(obj) ||
                TypeMatcher.isW_LongType(obj);

    }

}
